import socket

# 1创建客户端套接字
client_socket = socket.socket()
# 2连接服务端
server_ip = "localhost"
server_port = 8887
client_socket.connect((server_ip, server_port))
# 3向服务端发送数据
print("客户端发送数据")
client_socket.send("你好，我是socket client,刚进入网络学习".encode())
print("客户端接受信息")
s1 = client_socket.recv(1024)
print("受到服务器端的消息：", s1.decode())
# 4关闭自己的socket
client_socket.close()
